package com.cc.controller;

import com.cc.model.EbNews;
import com.cc.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Description: 用一句话描述
 * @Auther: 新梦想*陈超
 * @Date: 2020-10-30 13:26
 */
@Controller
@RequestMapping("/news")
public class NewsController {

    @Autowired
    private NewsService newsService;

    @RequestMapping("/detail")
    public String detail(Model model , int enId){
        System.out.println("====detail==="+enId);
        //1.调用service层的根据id查询新闻详情的方法
        EbNews ebNewsDetail =  newsService.findById(enId);
        //2.将数据绑定到model
        model.addAttribute("detail",ebNewsDetail);
        //3.返回view （jsp）
        return "news-view";//news-view.jsp
    }

}
